<?php

/**
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: TmacException.class.php 1402 2011-03-03 10:15:34Z zhangwentao $
 * http://www.t-mac.org； 
 */
class TmacException extends Exception
{

    /**
     * 优化异常页面
     *
     * @var string
     */
    private $html = '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Tmac罢工啦!!</title><style type="text/css">*{padding:0;margin:0;font-family:"微软雅黑", "宋体", Verdana, Geneva, sans-serif;font-size:12px;background-color:#EAF8F9}.box{width:600px;margin:20px auto;border:#99C4D5 solid 1px}.box .top{background:#C5E3E9;font-size:14px;padding:10px;color:#F30}.improtant{ color:#F60}.box .body{background:#ECF7F9;padding:10px;color:#0678A9}#footer{width:600px;margin:30px auto}#footer .myhr{background-color:#99C4D5;height:3px}#footer .body{padding:5px 10px;text-align:center;color:#4E4E4E;font-size:11px}</style></head><body><div class="box"><div class="top">Tmac罢工啦：%s</div><div class="body">在[<span class="improtant">%s</span>]的第[<span class="improtant">%s</span>]行. <br />%s</div></div><div id="footer"><div class="myhr"></div><div class="body">Powered by Tmac.</div></div></body></html>';
    private $html_redirect = '<!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>系统消息</title><meta http-equiv="content-type"content="text/html; charset=utf-8"><style type="text/css">body{font-size:12px;background-color:#EAF8F9}.alert{color:#FF9900;font-size:14px;margin-bottom:25px}.box{border:#FF9900 1px solid;width:460px;margin:100px auto;background-color:#FEFBE2;text-align:center;padding:30px}.alertmsg{margin-top:25px}</style></head><body style="text-align:center; height:10000px; width:100%%;"><div class="box"><h2 class="alert">%s</h2><div class="alertmsg"><a href="%s">将在<span id=\'backL\'></span>秒以后将返回如果你不想等待或浏览器没有自动跳转请点击这里跳转</a></div></div><script language="JavaScript">var url="%s";var t=%s;function later_back(){document.getElementById(\'backL\').innerHTML=t;t--;if(t==0)location.href=url;setTimeout("later_back();",1000)}later_back();</script></body></html>';

    /**
     * 构造器
     *
     * @param string $message
     * @param int $code
     * @access public
     */
    public function __construct($message = 'Unknown Error', $code = 0)
    {
        parent::__construct($message, $code);
    }

    /**
     * 输出异常信息
     *
     * @return void
     * @access public
     */
    public function getError()
    {
        if ($GLOBALS['TmacConfig']['Common']['debug']) {
            die(sprintf($this->html, urldecode($this->getMessage()), $this->getFile(), $this->getLine(), $this->getTraceAsString()));
        } else {
            die(sprintf($this->html_redirect, urldecode($this->getMessage()), '/', '/', 5));
        }
    }

}

?>
